<?php
require $this->website['path']['action'] . '/admin/islogin.php';

// 返回链接分页列表
//

$p = fn_post('p', 1);
$field = fn_post('field');
$value = fn_post('value');
$condition = fn_post('condition');

$json = array('status' => 'ok', 'msg' => 'paging', 'data' => '');

$this->website['class']['db']
	->table('link')
	->page($p)
	->order('id desc')
	->num($num)
	->field();

if ($field && $value && $condition) {
	switch ($condition) {
	case 'like':
		$this->website['class']['db']
			->where($field . ' like ?', '%' . $value . '%');
		break;
	default:
		$this->website['class']['db']
			->where($field . '=?', $value);
	}
}

$json['data'] = $this->website['class']['db']->paging();
$data = $json['data']['data'];
foreach ($data as &$v) {
	$tp = $this->website['class']['db']
		->table('type')
		->field('tit')
		->where('id=?', $v['tid'])
		->one();
	$v['ttit'] = $tp['tit'];
}
$json['data']['data'] = $data;

echo json_encode($json);